package com.chengliang.bbs.entry;

import lombok.Data;

import java.io.Serializable;

/**
 * @author chengliang
 */
@Data
public class Experience implements Serializable {

    /**
     * 主键
     */
    private Integer experienceId;

    /**
     * 用户主键
     */
    private Integer userId;

    /**
     * 总经验值
     */
    private Integer totalExperinceValue;

    /**
     * 7天经验值
     */
    private static final int sevenDaysExperienceValue = 10;
    /**
     * 15天经验值
     */
    private static final int fifteenDaysExperienceValue = 20;
    /**
     * 30天经验值
     */
    private static final int thirtyDaysExperienceValue = 30;
    /**
     * 100天经验
     */
    private static final int oneHundredDaysExperienceValue = 50;
    /**
     * 200天经验
     */
    private static final int twoHundredDaysExperienceValue = 70;
    /**
     * 365天经验
     */
    private static final int threeHundredAndSixtyFiveDaysExperienceValue = 100;

    /**
     * 根据天数计算经验值
     * * @param numberOfDays
     * * @return
     */
    public static Integer getExperienceValue(Integer numberOfDays) {
        if (numberOfDays < 7) {
            return 5;
        }
        if (numberOfDays >= 7) {
            return sevenDaysExperienceValue;
        }
        if (numberOfDays >= 15) {
            return fifteenDaysExperienceValue;
        }
        if (numberOfDays >= 30) {
            return thirtyDaysExperienceValue;
        }
        if (numberOfDays >= 100) {
            return oneHundredDaysExperienceValue;
        }
        if (numberOfDays >= 200) {
            return twoHundredDaysExperienceValue;
        }
        if (numberOfDays >= 365) {
            return threeHundredAndSixtyFiveDaysExperienceValue;
        }
        return 0;
    }
}